/**
 * Created by Administrator on 2017/1/3.
 */
function displayAbbreviations() {
    var supported = !document.getElementsByTagName || !document.createElement || !document.createTextNode;
    if (supported) {
        return false;
    }

    var abbreviations = document.getElementsByTagName('abbr');
    if (abbreviations.length < 1) {
        return false;
    }

    var definitions = [];
    var list = document.createElement('dl');
    for (var i = 0; i < abbreviations.length; i++) {
        var currentAbbr = abbreviations[i];
        if (currentAbbr.childNodes.length < 1) {
            continue;
        }

        var definition = currentAbbr.getAttribute('title');
        var key = currentAbbr.lastChild.nodeValue;
        definitions[key] = definition;

        var title = document.createElement('dt');
        var text = document.createTextNode(key);
        title.appendChild(text);

        var description = document.createElement('dd');
        text = document.createTextNode(definition);
        description.appendChild(text);

        list.appendChild(title);
        list.appendChild(description);
    }

    if (list.childNodes.length < 1) {
        return false;
    }

    var header = document.createElement('h2');
    text = document.createTextNode('Abbreviations');
    header.appendChild(text);

    document.body.appendChild(header);
    document.body.appendChild(list);
}

addLoadEvent(displayAbbreviations);